#ifndef SS_MODEL_H_
#define SS_MODEL_H_

#ifndef _countof
#define _countof(array) (sizeof(array)/sizeof(array[0]))
#endif

#ifndef __FIELDCOPY__
#ifdef WIN32
#define __FIELDCOPY__(field,dest)	strncpy_s(field,_countof(field),dest,_TRUNCATE)
#else
#define __FIELDCOPY__(field,dest)	strcpy(field, dest)
#endif
#endif

//--无效的MarketType值
#define VALID_MARKET_TYPE -999
//--无效的授信余额，若取到此值，说明没有向接口获得正确的授信余额，按照不限制额度的方式进行处理
#define VALID_CREDIT_BALANCE -999
//-------------------------------------------------------------------------------------
//--初始化char[]
#define _InitializeString(Name) \
    memset(Name, 0, _countof(Name));
//--由inItem中copy字段
#define _Copy_String_From_inItem(field)\
    strcpy(field, inItem.field);

//--内部类，不会被直接发送或接收，是其它消息类型的内部结构

namespace qb
{

	typedef char tcBondKey_c[64];
	typedef char tcListedMarket_c[8];
	typedef char tcUnderwriterID_c[33];
	typedef char tcUserID_c[33];
	typedef char tcUUID_c[33];

	//inner
	//
	//债券主键，BondKey与ListedMarket，内部类
	//xHyIDBBondPK
	class xHyIDBBondPK_c
	{
	public:
		//BondKey
		char		m_BondKey[32 + 1];				//bondkey
		//ListedMarket
		char		m_ListedMarket[8];				//市场
		//FunctionBegin
		//初始值
		xHyIDBBondPK_c()
		{
			memset(this, 0, sizeof(xHyIDBBondPK_c));
		}
		xHyIDBBondPK_c(const char* pBondKey, const char* pListedMarket)
		{
			__FIELDCOPY__(m_BondKey, pBondKey);
			__FIELDCOPY__(m_ListedMarket, pListedMarket);
		}
		xHyIDBBondPK_c(const std::string& strBondKey, const std::string& strListedMarket)
		{
			__FIELDCOPY__(m_BondKey, strBondKey.c_str());
			__FIELDCOPY__(m_ListedMarket, strListedMarket.c_str());
		}
		xHyIDBBondPK_c& operator=(const xHyIDBBondPK_c& inItem)
		{
			if (this == &inItem)
				return *this;
			__FIELDCOPY__(m_BondKey, inItem.m_BondKey);
			__FIELDCOPY__(m_ListedMarket, inItem.m_ListedMarket);
			return *this;
		}
		bool operator==(const xHyIDBBondPK_c& that) const
		{
			return (strcmp(this->m_BondKey, that.m_BondKey) == 0 && strcmp(this->m_ListedMarket, that.m_ListedMarket) == 0);
		}
		bool operator<(const xHyIDBBondPK_c& that) const
		{
			int iBondKeyCompare = strcmp(this->m_BondKey, that.m_BondKey);
			return  iBondKeyCompare == 0 ? strcmp(this->m_ListedMarket, that.m_ListedMarket) < 0 : iBondKeyCompare < 0;
		}
		void clear()
		{
			memset(this, 0, sizeof(xHyIDBBondPK_c));
		}
		void SetPK(const char* pBondKey, const char* pListedMarket)
		{
			__FIELDCOPY__(m_BondKey, pBondKey);
			__FIELDCOPY__(m_ListedMarket, pListedMarket);
		}
		//FunctionEnd
	};

	//inner
	//
	//报价记录中的QB信息类型（已公告，未公告均有）
	//xHyIDBQuoteQBUserInfo
	class xHyIDBQuoteQBUserInfo_c
	{
	public:
		//QBUserID
		tcUserID_c m_QBUserID;						//QB用户ID
		//QBUserName
		char m_QBUserName[64];						//QB用户名
		//QBInstitutionID
		tcUnderwriterID_c m_QBInstitutionID;					//QB机构ID
		//QBInstitutionName
		char m_QBInstitutionName[64];				//QB机构名
		//FunctionBegin
		//初始值
		xHyIDBQuoteQBUserInfo_c()
		{
			memset(this, 0, sizeof(xHyIDBQuoteQBUserInfo_c));
		}
		//FunctionEnd
	};

	//InvalidAreaBegin
	//宏源消息基类，包括了一些所有消息都需要的基础信息。
	class xHyIDBMsgBaseClass_c
	{
	public:
		//UnderwriterID
		tcUnderwriterID_c m_UnderwriterID;		//当前对应的一级分销商ID。对于一级分销商（PrimaryCentre端）来说为自身的ID；对于QB端来说应赋值为想要获取信息的分销商ID。
		int		m_Version;						//版本号，20160101...
		xHyIDBMsgBaseClass_c() :m_Version(0)
		{
			_InitializeString(m_UnderwriterID);
		}
	};
	//InvalidAreaEnd
}

#endif
